(function($){
	$.extend($.fn.tabs.methods, {   
	    /**
	     * 加载iframe内容  
	     * @param  {jq Object} jq     [description]  
	     * @param  {Object} params    params.which:tab的标题或者index;params.iframe:iframe的相关参数  
	     * @return {jq Object}        [description]  
	     */  
	    loadTabIframe:function(jq,params){   
	        return jq.each(function(){   
	            var $tab = $(this).tabs('getTab',params.which);   
	            if($tab==null) return;   
	            var $tabBody = $tab.panel('body');   
	            //销毁已有的iframe   
	            var $frame=$('iframe', $tabBody);   
	            if($frame.length>0){   
	                try{//跨域会拒绝访问，这里处理掉该异常   
	                    $frame[0].contentWindow.document.write('');   
	                    $frame[0].contentWindow.close();   
	                }catch(e){   
	                }   
	                $frame.remove();   
	                if (window.CollectGarbage) {
			            CollectGarbage();
			        }
	            }   
	            $tabBody.html('');   
	            $tabBody.css({'overflow':'hidden','position':'relative'});   
	            var $containter = $('<div style="position:absolute;width:96%;height:100%;z-index:0;"></div>').appendTo($tabBody);   
			    
	            var iframe = document.createElement("iframe");   
	            iframe.src = params.iframe.src;   
	            iframe.id = params.iframeid;
	            iframe.frameBorder = params.iframe.frameBorder || 0;   
	            iframe.height = params.iframe.height || '100%';   
	            iframe.width = params.iframe.width || '100%';   
	            if (iframe.attachEvent){   
	                iframe.attachEvent("onload", function(){
	                	
	                	jQuery($containter[0]).unblock({
	    		            onUnblock: function() {
	    		                jQuery($containter[0]).css('position', '');
	    		                jQuery($containter[0]).css('zoom', '');
	    		            }
	    		        });
	                	
	                });   
	            } else {   
	                iframe.onload = function(){   
	                	
	                	jQuery($containter[0]).unblock({
	    		            onUnblock: function() {
	    		                jQuery($containter[0]).css('position', '');
	    		                jQuery($containter[0]).css('zoom', '');
	    		            }
	    		        });
	                	
	                };   
	            }   
	            $containter[0].appendChild(iframe);   
	        });   
	    },   
	    /**
	     * 增加iframe模式的标签页  
	     * @param {[type]} jq     [description]  
	     * @param {[type]} params [description]  
	     */  
	    addIframeTab:function(jq,params){
	        return jq.each(function(){   
	            if(params.tab.href){   
	                delete params.tab.href;   
	            }   
	            $(this).tabs('add',params.tab);   
	            $(this).tabs('loadTabIframe',{'which':params.tab.title,'iframe':params.iframe,'iframeid':'iframe_'+params.tab.id});   
	        });   
	    },   
	    /**
	     * 更新tab的iframe内容  
	     * @param  {jq Object} jq     [description]  
	     * @param  {Object} params [description]  
	     * @return {jq Object}        [description]  
	     */  
	    updateIframeTab:function(jq,params){   
	        return jq.each(function(){   
	            params.iframe = params.iframe || {};   
	            if(!params.iframe.src){   
	                var $tab = $(this).tabs('getTab',params.which);   
	                if($tab==null) return;   
	                var $tabBody = $tab.panel('body');   
	                var $iframe = $tabBody.find('iframe');   
	                if($iframe.length===0) return;   
	                $.extend(params.iframe,{'src':$iframe.attr('src')});   
	            }   
	            $(this).tabs('loadTabIframe',params);   
	        });   
	    }   
	});  
})(jQuery);
